<?php
/**
 * @package Joomla
 * @subpackage Jmonoslideshow
 * @copyright (C) 2010 - Matthieu BARBE - www.ccomca.com
 * @license GNU/GPL v2
 * 
 * Jmonoslideshow is a Joomla extension for Monoslideshow.
 *
 * Jmonoslideshow uses :
 * Monoslideshow (http://www.monoslideshow.com/)
 * Plupload (http://www.plupload.com/) by Moxicode Systems
 * json class by Michal Migurski, Matt Knapp, Brett Stimmerman
 * jquery a JavaScript Library (http://jquery.com/)
 * getid3 library (http://getid3.sourceforge.net/)
 * swfobject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file (http://code.google.com/p/swfobject/)
 * Chained Selects jQuery Plugin (http://www.appelsiini.net/2010/jquery-chained-selects)
 *
 * Jmonoslideshow is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

JHTML::stylesheet( 'monoslideshow.css', 'administrator/components/com_jmonoslideshow/assets/css/' );

$params = &JComponentHelper::getParams( 'com_jmonoslideshow' );
$tooltips_image = $params->get( 'tooltips_image', 1 );

if ($tooltips_image == 1) 
	{
	JHTML::_('behavior.tooltip');
	$doc = &JFactory::getDocument();
	$doc->addScriptDeclaration("
	window.addEvent('domready', function() {
	var zoomTip = new Tips($$('.zoomTip'), {
		className: 'custom', //this is the prefix for the CSS class
		initialize:function() {
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
	});	
	");
	
	$doc->addStyleDeclaration('
	.custom-tip {
	color: #000;
	z-index: 13000;
	}
	.custom-title {
		font-weight: bold;
		font-size: 12px;
		margin: 0;
		color: #fff;
		padding: 8px 8px 4px;
		background: #e91579;
		border-bottom: 1px solid #B5CF74;
	}
	.custom-text {
		font-size: 11px;
		padding: 4px 8px 8px;
		background: #29a0cf;
	}				  
	');
	}


$ordering = ($this->lists['order'] == 'a.ordering');
?>
<form action="index.php" method="post" name="adminForm">


<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'COM_JMONOSLIDESHOW_FILTER' ); ?>:
		<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
		<button onclick="this.form.submit();"><?php echo JText::_( 'COM_JMONOSLIDESHOW_GO' ); ?></button>
		<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_catid').value='0';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'COM_JMONOSLIDESHOW_RESET' ); ?></button>
	</td>
	<td nowrap="nowrap">
		<?php
			echo $this->lists['catid'];
			echo $this->lists['state'];
			echo $this->selectTypeList;
		?>
	</td>
</tr>
</table>

<div id="editcell">
	<table class="adminlist">
	<thead>
		<tr>
			<th width="5">
				#
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
			</th>
			<th>
				<?php echo JText::_( 'COM_JMONOSLIDESHOW_MEDIA' ); ?>
			</th>
          
            <th>
            <?php echo JHTML::_('grid.sort',  'COM_JMONOSLIDESHOW_TITLE', 'a.title', $this->lists['order_Dir'], $this->lists['order'] ); ?>
            </th>
              <th>
				<?php echo JText::_( 'COM_JMONOSLIDESHOW_TYPE' ); ?>
				
			</th>
			<th>
				<?php echo JHTML::_('grid.sort',  'COM_JMONOSLIDESHOW_CATEGORY', 'cc.title', $this->lists['order_Dir'], $this->lists['order'] ); ?>
			</th>
             <th>
				<?php echo JText::_( 'COM_JMONOSLIDESHOW_ALBUM' ); ?>
				
			</th>
            <th width="8%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',  'COM_JMONOSLIDESHOW_ORDER', 'a.ordering', $this->lists['order_Dir'], $this->lists['order'] ); ?>
				<?php if ($ordering) echo JHTML::_('grid.order',  $this->items ); ?>
			</th>
            
            <th width="5%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',  'COM_JMONOSLIDESHOW_PUBLISHED', 'a.published', $this->lists['order_Dir'], $this->lists['order'] ); ?>
			</th>
            <th width="5">
				<?php echo JHTML::_('grid.sort',  'COM_JMONOSLIDESHOW_ID', 'a.id', $this->lists['order_Dir'], $this->lists['order'] ); ?> 
			</th>
            
		</tr>
	</thead>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)
	{
		$row = &$this->items[$i];
		$checked = JHTML::_('grid.checkedout',   $row, $i );
		$link = JRoute::_( 'index.php?option=com_jmonoslideshow&controller=images&task=edit&cid[]='. $row->id );
		$published 	= JHTML::_('grid.published', $row, $i );
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<?php echo $this->pagination->getRowOffset( $i ); ?>
			</td>
			<td>
				<?php echo $checked; ?>
			</td>
			<td>
				<a href="<?php if (  JTable::isCheckedOut($this->user->get ('id'), $row->checked_out ) ) echo "#"; else echo $link; ?>" <?php if ($tooltips_image == 1) : ?> class="zoomTip" title="<?php echo JText::_( 'COM_JMONOSLIDESHOW_SOURCE' );  ?> : <?php echo JText::_( MediaHelper::getTypeName($row->type)); ?><?php if (  JTable::isCheckedOut($this->user->get ('id'), $row->checked_out ) ) echo " (".JText::_( 'COM_JMONOSLIDESHOW_CHECKED-IN' ).")"; ?>::<?php echo MediaHelper::getInfoMedia($row->type, $row->id,  $row->extension); ?>"><?php endif; ?><img src="<?php echo JURI::root(); ?>images/monoslideshow/images/thumbnails/<?php echo $row->id; ?>.<?php if ($row->extension == "png") echo "png"; else echo "jpg"; ?>" /></a>
			</td>
            
            <td>
				 <?php if (  JTable::isCheckedOut($this->user->get ('id'), $row->checked_out ) ) {
					echo $this->escape($row->title);
				} else {
				?>
				
					<a href="<?php echo $link; ?>">
						<?php echo $this->escape($row->title); ?></a>
				<?php
				} ?>
			</td>
            
            <td>
				<?php echo JText::_( MediaHelper::getTypeName($row->type)); ?>
			</td>
            
			<td>
				<?php echo $row->category; ?>
			</td>
            
            <td>
				<?php if ($row->albumtitle == "") echo JText::_( 'COM_JMONOSLIDESHOW_NO_ALBUM' );; echo $row->albumtitle; ?>
			</td>
            
            <td class="order">
				<span><?php echo $this->pagination->orderUpIcon( $i, ($row->catid == @$this->items[$i-1]->catid),'orderup', 'Move Up', $ordering ); ?></span>
				<span><?php echo $this->pagination->orderDownIcon( $i, $n, ($row->catid == @$this->items[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?></span>
				<?php $disabled = $ordering ?  '' : 'disabled="disabled"'; ?>
				<input type="text" name="order[]" size="5" value="<?php echo $row->ordering;?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />
			</td>
            
            <td align="center">
				<?php echo $published;?>
			</td>
            
            <td>
				<?php echo $row->id; ?>
			</td>
            
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	 <tfoot>
    <tr>
      <td colspan="10">
      	<?php echo $this->pagination->getListFooter(); ?>
      </td>
    </tr>
  </tfoot>
	</table>
</div>

<input type="hidden" name="option" value="com_jmonoslideshow" />
<input type="hidden" name="view" value="images" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="images" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
